package com.NewsServlet;

import com.NewsService.NewsService;
import com.NewsServiceImpl.NewsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class DeleAjaxServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            int newId = Integer.parseInt(request.getParameter("id"));
            NewsService newsService = new NewsServiceImpl();
            int count = newsService.ServiceSdeleteById(newId);
            response.setCharacterEncoding("text/html;charset=UTF-8");
             PrintWriter printWriter=response.getWriter();
            if (count > 0) {
                printWriter.print(count);
            } else {
                printWriter.print(-1);
            }
            printWriter.flush();
            printWriter.close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
